package org.example.cake.controller;

import org.example.cake.entity.Admin;
import org.example.cake.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.example.cake.common.Rep;
import org.example.cake.entity.Admin;
import org.example.cake.entity.User;
import org.example.cake.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    public AdminService adminService;

//    /**
//     * //管理员登录
//     * @author 徐
//     * @param username 管理员账号
//     * @param password 管理员密码
//     * @date 2025-07-25
//     * @return 管理员对象
//     */
    @PostMapping("/adminLoginEnd")
    public Rep adminLogin(@RequestBody Admin admin){
        String username=admin.getUsername();
        String password = admin.getPassword();
        System.out.println("用户名"+username+"密码 = " + password);
        Admin admin1 = adminService.adminLogin(username, password);
        System.out.println("管理员 = " + admin1);
        Rep rep=new Rep();
        if (admin1!=null){
            return rep.addData("admin",admin1);
        }else {
            System.out.println("用户名或密码错误");
             return rep;
        }
    }







}
